package session2.constructor;

public class Animal2 {
	String name;

	Animal2() {
		this(makeRandomName());
	}

	Animal2(String name) {
		this.name = name;
	}

	static String makeRandomName() {
		int x = (int) (Math.random() * 5);
		// String name = new String[] { "Fluffy", "Fido", "Rover", "Spike",
		// "Gigi" }[x];
		// return name;
		// Tuong duong;
		
		String nameList[] = new String[] { "Fluffy", "Fido", "Rover", "Spike",
				"Gigi" };
		String name = nameList[x];
		return name;

	}

	public static void main(String[] args) {
		Animal2 a = new Animal2();
		System.out.println("Animal2.java: " + a.name);
		//
		// Animal2 b = new Animal2("Zeus");
		// System.out.println("Animal2.java: " + b.name);
	}
}